package response

import (
	"github.com/EDDYCJY/go-gin-app/pkg/e"
	"github.com/gin-gonic/gin"
	"net/http"
)

func ApiReturn(c *gin.Context, code int,data interface{}, msg string)  {
	if msg == "" {
		msg = e.GetMsg(code)
	}
	c.JSON(http.StatusOK,gin.H{
		"code":code,
		"msg":msg,
		"data":data,
	})
}

func FailReturn(c *gin.Context, httpCode int,code int, msg string) {
	if msg == "" {
		msg = e.GetMsg(code)
	}
	c.JSON(httpCode,gin.H{
		"code":code,
		"msg":msg,
		"data":make(map[string]string),
	})
}
